/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package comandaXM.vista.informes;

import comandaXM.classes.informes.Dtproveidors;
import comandaXM.accions.ProveidorsAct;
import comandaXM.classes.manteniment.proveidor.Proveidor;
import java.util.ArrayList;
import java.util.List;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JasperViewer;

/**
 *
 * @author xmarti
 */
public class TestReport {
  
    private ProveidorsAct act= new ProveidorsAct(); 
    public static void main(String[] args) throws Exception 
    { 
        Dtproveidors datasource = new Dtproveidors();  
        List <Proveidor> proveidors= new ArrayList<Proveidor>(); 
        Proveidor p = new Proveidor(); 
        p.setCif("1");
        p.setNomFiscal("proveidor1");
        p.setPoblacio("llambilles");
        proveidors.add(p); 
        p= new Proveidor();         
        p.setCif("2");
        p.setNomFiscal("proveidor2");
        p.setPoblacio("Flaça");
        proveidors.add(p); 
        datasource.setProveidors(proveidors);
        
        JasperReport reporte = (JasperReport) JRLoader.loadObject(System.getProperty ("user.dir")+"\\build\\classes\\comandaxm\\vista\\informes\\ReportProveidor.jasper");  
        //JasperReport reporte = (JasperReport) JRLoader.loadObject("ReportProveidor.jasper");  
        JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, datasource);  
        JasperViewer.viewReport( jasperPrint, false);
//        JRExporter exporter = new JRPdfExporter();  
//        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); 
//        exporter.setParameter(JRExporterParameter.OUTPUT_FILE, new java.io.File("ReportProveidor.xls")); 
//        exporter.exportReport(); 
    }
}
    

